package com.harkjeans.javacoding.basic;

/**
 * ClassName: Exercise4
 * Package: com.harkjeans.javacoding.basic
 * Description: 练习4:复制数组
 *
 * @Author harkjeans
 * @Create 2025/10/14 14:36
 * @Version 1.0
 */

/**
 * 把一个数组中的元素复制到另一个新数组中去。
 */
public class Exercise4 {
    public static void main(String[] args) {
        int[] arr = new int[]{1, 2, 3, 4, 5};
        int[]res = copyArray(arr);
        for (int i = 0; i < arr.length; i++) {
            System.out.print(res[i] + " ");
        }
        System.out.println();
    }

    public static int[] copyArray(int[] arr){
        int[] res = new int[arr.length];
        for (int i = 0; i < arr.length; i++) {
            res[i] = arr[i];
        }
        return res;
    }


}

